#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    ui->pushButton_up->setIcon(QIcon(":/image/up.png"));
    ui->pushButton_down->setIcon(QIcon(":/image/down.png"));
    ui->pushButton_left->setIcon(QIcon(":/image/left.png"));
    ui->pushButton_right->setIcon(QIcon(":/image/right.png"));
    ui->pushButton_lufei->setIcon(QIcon(":/image/lufei.gif"));
    ui->pushButton_lufei->setIconSize(QSize(80,60));
    ui->pushButton_up->setIconSize(QSize(61,51));
    ui->pushButton_down->setIconSize(QSize(61,51));
    ui->pushButton_left->setIconSize(QSize(61,51));
    ui->pushButton_right->setIconSize(QSize(61,51));
    //设置快捷键
    ui->pushButton_up->setShortcut(QKeySequence("ctrl+w"));
    ui->pushButton_down->setShortcut(QKeySequence("ctrl+s"));
    ui->pushButton_left->setShortcut(QKeySequence("ctrl+a"));
    ui->pushButton_right->setShortcut(QKeySequence("ctrl+d"));
    //开启鼠标连击
    ui->pushButton_up->setAutoRepeat(true);
    ui->pushButton_down->setAutoRepeat(true);
    ui->pushButton_left->setAutoRepeat(true);
    ui->pushButton_right->setAutoRepeat(true);


    ui->radioButton_male->setChecked(true);
    ui->label_xingbie->setText("您选择的性别为:男");

   // ui->radioButton_else->setCheckable(false);
    ui->radioButton_else->setEnabled(false);


}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_day_clicked()
{
    this->setStyleSheet("background-color:rgb(240,240,240);");
    ui->plainTextEdit->setStyleSheet("background-color:white;color:black");
    ui->pushButton_day->setStyleSheet("color:black;");
    ui->pushButton_night->setStyleSheet("color:black;");
}

void Widget::on_pushButton_night_clicked()
{
    this->setStyleSheet("background-color:black;");
    ui->plainTextEdit->setStyleSheet("background-color:black;color:white");
    ui->pushButton_night->setStyleSheet("color:white;");
    ui->pushButton_day->setStyleSheet("color:white;");
}

void Widget::on_pushButton_up_clicked()
{
    QRect rect=ui->pushButton_lufei->geometry();
    ui->pushButton_lufei->setGeometry(rect.x(),rect.y()-5,rect.width(),rect.height());
}

void Widget::on_pushButton_down_clicked()
{
    QRect rect=ui->pushButton_lufei->geometry();
    ui->pushButton_lufei->setGeometry(rect.x(),rect.y()+5,rect.width(),rect.height());
}

void Widget::on_pushButton_left_clicked()
{
    QRect rect=ui->pushButton_lufei->geometry();
    ui->pushButton_lufei->setGeometry(rect.x()-5,rect.y(),rect.width(),rect.height());
}

void Widget::on_pushButton_right_clicked()
{
    QRect rect=ui->pushButton_lufei->geometry();
    ui->pushButton_lufei->setGeometry(rect.x()+5,rect.y(),rect.width(),rect.height());
}

void Widget::on_radioButton_male_clicked()
{
    ui->label_xingbie->setText("您选择的性别为:男");
}

void Widget::on_radioButton_women_clicked()
{
    ui->label_xingbie->setText("您选择的性别为:女");
}

void Widget::on_radioButton_else_clicked()
{
    ui->label_xingbie->setText("您选择的性别为:其他");
}

void Widget::on_pushButton_clicked()
{
    QString result="今天你的安排是：";
    if(ui->checkBox->isChecked())
    {
        result+=ui->checkBox->text()+" ";
    }
    if(ui->checkBox_2->isChecked())
    {
        result+=ui->checkBox_2->text()+" ";
    }
    if(ui->checkBox_3->isChecked())
    {
        result+=ui->checkBox_3->text()+" ";
    }
    ui->label_2->setText(result);
}
